<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script src="../node_modules/vue/dist/vue.js"></script>

<div id="app">
    <button @click="count++">被点击了：{{count}}次</button>
    <counter></counter>
    <button-counter></button-counter>
</div>

<script>
        // 声明全局组件
        Vue.component("counter",{
            template: `<button @click="count++">被点击了：{{count}}次</button>`,
            data(){
                return{
                    count:1
                }
            }
        })
        // 声明局部组件
        const buttonCounter = {
            template: `<button @click="count++">被点击了：{{count}}次~~~~</button>`,
            data(){
                return{
                    count:1
                }
            }
        }
        new Vue({
            el: "#app",
            data:{
                count:1
            },
            components:{
                'button-counter': buttonCounter
            }
        })
    </script>
</body>
</html>